package cn.itcast.config;

import jdk.nashorn.internal.objects.annotations.Property;
import org.springframework.beans.PropertyAccessException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;

import javax.activation.DataSource;


public class DBConfig {

@PropertySource("classpath:jdbc.properties")
public class DBCconfig{
    @Value("${jdbc.driver}")
    private String driver;
    @Value("${jdbc.url}")
    private String url;
    @Value("${jdbc.username}")
    private String username;
    @Value("${jdbc.password}")
    private String password;

}
@Bean("dataSource")
public DataSource getDataSource()throws PropertyAccessException {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

    DataSource bean = context.getBean(DataSource.class);
    return bean;
}

}
